package models;

import javax.persistence.Entity;
import play.data.validation.Email;
import play.data.validation.MaxSize;
import play.data.validation.MinSize;
import play.data.validation.Password;
import play.data.validation.Required;
import play.db.jpa.Model;


@Entity
public class Usuario extends Model{
    @Required
    @MaxSize(30)
    @MinSize(3)
    public String usuario;
    @Required
    @MaxSize(50)
    @MinSize(3)
    public String nombre;
    @Required
    @MaxSize(50)
    @MinSize(3)
    @Password
    public String password;
    @Email
    public String email;

    public Usuario(String usuario, String nombre, String password, String email) {
        this.usuario = usuario;
        this.nombre = nombre;
        this.password = password;
        this.email = email;
    }

  public static Usuario conectar(String usuario, String password){
      return find("byUsuarioAndPassword", usuario, password).first();
  }

    @Override
    public String toString() {
        return usuario;
    }
  
  
  
}
